package com.lanyou.esb.cook.proxy.meta;

import java.rmi.NoSuchObjectException;

import org.apache.commons.lang3.StringUtils;

import com.lanyou.esb.cook.proxy.common.SystemResCode;

/**
 * 校验类型<br>
 * 描述：<br>
 * 0：无校验；1：基础校验；2:自定义OAUTH2校验；3：Web Service校验
 * 
 * @author Davey.wu
 */
public enum AuthType {

	NOAUTH("0"), HTTP_BASIC_KEY("1"), OAUTH("2"), WS_SECURITY("3");

	public static final String TypeCode = "20001";

	public final String ValueCode;

	private AuthType(String code) {
		this.ValueCode = code;
	}

	public static AuthType get(String valueCode)
			throws NoSuchObjectException {
		if (StringUtils.isBlank(valueCode)) {
			throw new NullPointerException();
		}
		for (AuthType type : AuthType.values()) {
			if (type.ValueCode.equals(valueCode)) {
				return type;
			}
		}
		throw new NoSuchObjectException(SystemResCode.MSG_AUTH_TYPE_NOT_SUPPORT
				+ "(AuthModeType=" + valueCode + ")");
	}
}
